<?php
/**
@author 
@copyright 2008
 */
// Load JsHttpRequest backend.
require_once $_SERVER['DOCUMENT_ROOT']."/admin/js/JsHttpRequest/JsHttpRequest.php";
// Create main library object. You MUST specify page encoding!
$JsHttpRequest =& new JsHttpRequest("UTF-8");
// Store resulting data in $_RESULT array (will appear in req.responseJs).



define ("DIRECT_ACCESS", true);
include_once ($_SERVER['DOCUMENT_ROOT']."/conf/conf.php");
$smarty=init_smarty("admin");
$smarty->assign("ADMIN_URL",ADMIN_URL);
$smarty->assign("SITE_URL",SITE_URL);
/** START **/
if(isset($_REQUEST['adminflag'])&&$_REQUEST['admin']!='0')
	$adminflag=$_REQUEST['adminflag'];
else
	die("Ошибка!");
switch($adminflag)
{
	case 'admin':
		$dir='admin';
		$table=PFX."admin_tree";
		break;
	case 'content':
		$dir='content';
		$table=PFX."site_tree";
		break;
	case 'category':
		$dir='category';
		$table=PFX."category_ru";
		break;
	case 'catalog':
		$dir='catalog';
		$table=PFX."catalog_ru";
		break;
}
$p=$_REQUEST['pid'];
$parent = $db->fetch_one("SELECT * FROM $table WHERE id=$p");
switch($adminflag)
{
	case 'admin':
		$item['pid']=$p;
		$item['module']=$parent['module'];
		$item['template']=$parent['template'];
		$item['dir']=$parent['dir'];
		break;
	case 'content':
		$item['pid']=$p;
		$item['module']=$parent['module'];
		$item['template']=$parent['template'];
		$item['dir']=$parent['dir'];
		break;
	case 'category':
		$item['pid']=$p;
		$item['module']=$parent['module'];
		break;
	case 'catalog':
		$item['pid']=$p;
		break;
}
$smarty->assign("item",$item);
$smarty->assign("action","add");
$output = $smarty->fetch("modules/".$dir.TMPL_DIR."editor.html");
/** END **/
$GLOBALS['_RESULT']=array('output'=>$output);
?>